<template>
  <div v-show="$store.state.design.shadeState === 4 || $store.state.design.shadeState ===6" class="savebox">
    <div class="savetitle">Warm tips</div>
    <div class="closesave" @click="$store.commit('design/setShadeState',0)" />
    <div v-show="$store.state.design.shadeState === 4" style="height:190px;font-size: 20px;line-height: 190px;">
      {{ $store.state.design.title === ''?'Your design has not been saved!Save or leave?':'You have finished your design.Inquiry or leave?' }}
    </div>
    <div v-show="$store.state.design.shadeState === 6" style="height:190px;font-size: 20px;line-height: 190px;">
      Are you sure you want to leave this model?
    </div>
    <div v-show="$store.state.design.shadeState === 4" class="addtextbtn spcbtn leavebtn" @click="leave">Leave</div>
    <div v-show="$store.state.design.shadeState === 4" class="addtextbtn spcbtn surebtn" @click="saveOrInquiry">
      {{ $store.state.design.title === ''?'Save':'Inquiry' }}
    </div>
    <div v-show="$store.state.design.shadeState === 6" class="addtextbtn spcbtn leavebtn" @click="handleConfirm">Confirm</div>
    <div v-show="$store.state.design.shadeState === 6" class="addtextbtn spcbtn surebtn" @click="$store.commit('design/setShadeState',0)">Cancel</div>
  </div>
</template>
<script>
export default {
  methods: {
    leave() {
      window.parent &&
        window.parent.product &&
        window.parent.product.closedesign &&
        window.parent.product.closedesign();
    },
    saveOrInquiry() {
      if (this.$store.state.design.title === '') {
        this.$store.commit('design/setShadeState', 3);
        saveInServer(function() {
          window.myStore.commit('design/setShadeState', 3);
          window.parent &&
            window.parent.product &&
            window.parent.product.addtocart(
              globalData.query.product_id,
              globalData.saveDesign,
              true
            );
        });
      } else {
        window.parent &&
          window.parent.product &&
          window.parent.product.clickInquiry &&
          window.parent.product.clickInquiry();
      }
    },
    handleConfirm() {
      console.log('confirm');
      // this.$store.commit('design/initVue');
      // svgTool.init();
      // initConfig({
      //   designid: globalData.toDesign,
      //   product_id: globalData.toProduct
      // });
      // window.BLS &&
      //   window.BLS.getResourceById &&
      //   window.BLS.getResourceById(globalData.toDesign);
      this.$router.push({
        path: '/onlineDesign',
        query: {
          designId: globalData.toDesign
        }
      });
      window.location.reload();
    }
  }
};
</script>
<style lang="scss" scoped>
.savebox{
  position: absolute;
  top:50%;
  left:50%;
  -webkit-transform: translate(-50%,-50%);
          transform: translate(-50%,-50%);
}
.savebox{
  width: 650px;
  height: 400px;
  background-color: #fff;
  text-align: center;
}
.savetitle{
  height: 99px;
  border-bottom: 1px solid #DBD9DA;
  text-align: center;
  font-size: 24px;
  line-height: 99px;
  font-weight: 700;
}

.closesave{
  position: absolute;
  top: 0;
  right: 0;
  width: 99px;
  height: 99px;
  cursor: pointer;
  background: url('/static/image/cl.png') no-repeat 42px 42px;
  z-index: 1;
}
.closesave:hover{
  background-image: url('/static/image/cl1.png');
}

.addtextbtn{
  width: 150px;
  text-align: center;
  height: 37px;
  line-height: 37px;
  color: #666;
  border: 1px solid #DBD9DA;
  cursor: pointer;
  margin: 0 20px 0 auto;
  font-weight: 600;
}
.addtextbtn:hover{
  color: #339;
  border-color: #339;
}
.addtextbtn.spcbtn {
  display: inline-block;
}
.addtextbtn.surebtn {
  margin: 0;
  color: #339;
  border-color: #339;
}
.addtextbtn.leavebtn:hover {
  color: #fff;
  background-color: #dbd9da;
  border-color: #fff;
}
.addtextbtn.surebtn:hover {
  color: #fff;
  background-color: #339;
}
</style>

// WEBPACK FOOTER //
// src/components/warm-prompt.vue
